﻿// Implement CBL JobType
// Match Name Dot & Match Second Name No Dot. Gom chung lai het, hoan chinh ham MatchPerson
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;

namespace DienLib.SummitLib
{
    //[StructLayout(LayoutKind.Sequential)]
    public struct PERFROW
    {
        public PERFROW(uint gun, uint run, double mTopShot, double mBotShot, Enums.GunSize gunSize, Enums.SPF sPF, Enums.Polarity polarity, string comment)
        {
            this._Gun = gun;
            this._Run = run;
            this._TopShot = mTopShot;
            this._BottomShot = mBotShot;
            this._GunSize = gunSize;
            this._ShotDensity = sPF;
            this._Polarity = polarity;
            this._Comment = comment;
        }

        public string GetGun()
        {
            return _Gun.ToString();
        }

        public string GetRun()
        {
            return _Run.ToString();
        }

        public string GetTopShot()
        {
            return _TopShot.ToString();
        }

        public string GetBottomShot()
        {
            return _BottomShot.ToString();
        }

        public string GetGunSize()
        {
            return Enums.eGunSize.ToData(_GunSize);
        }

        public string GetShotDensity()
        {
            return Enums.eSPF.ToData(_ShotDensity);
        }

        public string GetPolarity()
        {
            return Enums.ePolarity.ToData(_Polarity);
        }

        private uint _Gun;
        public uint Gun
        {
            get { return _Gun; }
            set { _Gun = value; }
        }

        private uint _Run;
        public uint Run
        {
            get { return _Run; }
            set { _Run = value; }
        }

        private double _TopShot;
        public double TopShot
        {
            get { return _TopShot; }
            set { _TopShot = value; }
        }

        private double _BottomShot;
        public double BottomShot
        {
            get { return _BottomShot; }
            set { _BottomShot = value; }
        }

        private Enums.GunSize _GunSize;
        public Enums.GunSize GunSize
        {
            get { return _GunSize; }
            set { _GunSize = value; }
        }

        private Enums.SPF _ShotDensity;
        public Enums.SPF ShotDensity
        {
            get { return _ShotDensity; }
            set { _ShotDensity = value; }
        }

        private Enums.Polarity _Polarity;
        public Enums.Polarity Polarity
        {
            get { return _Polarity; }
            set { _Polarity = value; }
        }

        private string _Comment;
        public string Comment
        {
            get { return _Comment; }
            set { _Comment = value; }
        }
    }

    //[StructLayout(LayoutKind.Sequential)]
    public struct SERVICEROW
    {
        public SERVICEROW(string serviceName, uint run, double mTopMD, double mBottomMD, string comment)
            : this()
        {
            this.ServiceName = serviceName;
            this.Run = run;
            this.TopMD = mTopMD;
            this.BottomMD = mBottomMD;
            this.Comment = comment;
        }

        public string ServiceName { get; private set; }
        public uint Run { get; private set; }
        public double TopMD { get; private set; }
        public double BottomMD { get; private set; }
        public string Comment { get; private set; }
    }

    public class Enums
    {
        #region Customer
        public enum Customer { NA, PTTEP, CHEVRON };
        public static class eCustomer
        {
            private static string[] _arr = { "N/A", "PTT EXPLORATION AND PRODUCTION", "CHEVRON THAILAND EXPL AND PROD EBUS" };
            private static string[] _arr2 = { "N/A", "PTT EXPLORATION AND PRODUCTION (317673)", "CHEVRON THAILAND EXPL AND PROD EBUS (348404)" };

            /// <summary>
            /// to "Customer Name" in Summit Job Package
            /// </summary>
            /// <param name="enumer"></param>
            /// <returns></returns>
            public static string ToData(Customer enumer)
            {
                return _arr[(int)enumer];
            }

            /// <summary>
            /// "Customer View" in Summit Main Form (Same as ToDate plus add SAP Number with Bracket ()
            /// </summary>
            /// <param name="enumer">Customer Enum</param>
            /// <returns>string appear in "Customer View" of Summit Main Form</returns>
            public static string ToView(Customer enumer)
            {
                return _arr2[(int)enumer];
            }

            /// <summary>
            /// From Customer Name in Summit Job Package to Enum Customer
            /// </summary>
            /// <param name="data"></param>
            /// <returns></returns>
            public static Customer ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return Customer.NA;
                return (Customer)tmp;
            }
        }
        #endregion

        #region WellType
        public enum WellType { NA, AIR, BRINE, CO2, GAS, HELI, N2, OIL, STEAM, WATER };
        public static class eWellType
        {
            private static string[] _arr = { "N/A", "Air", "Brine", "CO2", "Gas", "Helium", "N2", "Oil", "Steam", "Water" };
            public static string ToData(WellType enumer)
            {
                return _arr[(int)enumer];
            }
            public static WellType ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return WellType.NA;
                return (WellType)tmp;
            }
        }
        #endregion

        #region JobStatus
        public enum JobStatus { NA, ACTIVE, DISPATCHED, INCOMPLETE_DOC, CANCELLED, DECLINED, PACKET_COMPLETE, SCHEDULED, SITE_COMPLETE, PENDING_WILLCALL };
        public static class eJobStatus
        {
            private static string[] _arr = { "N/A", "Active", "Dispatched", "Incomplete Documentation", "Job Cancelled", "Job Declined (By HES)", 
                                                "Job Packet Complete", "Job Scheduled", "Job Site Activities Complete", "Pending/Will-Call" };
            public static string ToData(JobStatus enumer)
            {
                return _arr[(int)enumer];
            }
            public static JobStatus ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return JobStatus.NA;
                return (JobStatus)tmp;
            }
        }
        #endregion

        #region JobType
        public enum JobType { NA, PERF, CBL };
        public static class eJobType
        {
            private static string[] _arr = { "N/A", "7548 - PERFORATING - OTHERS BOM", "7549 - CEMENT & CASING EVAL BOM" };
            public static string ToData(JobType enumer)
            {
                return _arr[(int)enumer];
            }
            public static JobType ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return JobType.NA;
                return (JobType)tmp;
            }
        }
        #endregion

        #region ServiceCenter
        public enum ServiceCenter { NA, THAILAND };
        public static class eServiceCenter
        {
            private static string[] _arr = { "N/A", "1041 Halliburton Energy Services" };
            public static string ToData(ServiceCenter enumer)
            {
                return _arr[(int)enumer];
            }
            public static ServiceCenter ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return ServiceCenter.NA;
                return (ServiceCenter)tmp;
            }
        }
        #endregion

        #region Country
        public enum Country { NA, THAILAND };
        public static class eCountry
        {
            private static string[] _arr = { "N/A", "Thailand" };
            public static string ToData(Country enumer)
            {
                return _arr[(int)enumer];
            }
            public static Country ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return Country.NA;
                return (Country)tmp;
            }
        }
        #endregion

        #region State/Province
        public enum State { NA };
        public static class eState
        {
            private static string[] _arr = { "N/A" };
            public static string ToData(State enumer)
            {
                return _arr[(int)enumer];
            }
            public static State ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return State.NA;
                return (State)tmp;
            }
        }
        #endregion

        #region Location
        public enum Location { NA, LAND, INLAND_WATER, STATE_WATER, FEDERAL_WATER, DEEP_WATER, ULTRADEEP_WATER };
        public static class eLocation
        {
            private static string[] _arr = { "N/A", "Land", "Inland Waters", "State Waters", "Federal Waters", "DeepWtr(1000-5000ft)", "Ultr Deepwtr >5000ft" };
            public static string ToData(Location enumer)
            {
                return _arr[(int)enumer];
            }
            public static Location ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return Location.NA;
                return (Location)tmp;
            }
        }
        #endregion

        #region CO2Present
        public enum CO2Present { NA, NO, YES, UNKNOWN };
        public static class eCO2Present
        {
            private static string[] _arr = { "N/A", "No", "Yes", "Unknown" };
            public static string ToData(CO2Present enumer)
            {
                return _arr[(int)enumer];
            }
            public static CO2Present ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return CO2Present.NA;
                return (CO2Present)tmp;
            }
        }
        #endregion

        #region H2SPresent
        public enum H2SPresent { NA, NO, YES, UNKNOWN };
        public static class eH2SPresent
        {
            private static string[] _arr = { "N/A", "No", "Yes", "Unknown" };
            public static string ToData(H2SPresent enumer)
            {
                return _arr[(int)enumer];
            }
            public static H2SPresent ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return H2SPresent.NA;
                return (H2SPresent)tmp;
            }
        }
        #endregion

        #region WellFluid
        public enum WellFluid
        {
            NA, AIR, BRINE, CRUDE_OIL, DRILL_WATER, FOAM, FRESH_WATER, GLYCOL_BASED, NITROGEN, OIL_BASED, OTHER,
            PRODUCED_GAS, PRODUCED_OIL, PRODUCED_WATER, SALT_WATER, SEA_WATER, UNKNOWN, WATER_BASED
        };
        public static class eWellFluid
        {
            private static string[] _arr = { "N/A", "Air", "Brine", "Crude Oil", "Drill Water", "Foam", "Fresh Water", "Glycol-Based", "Nitrogen", "Oil Based", "Other", 
                                             "Produced Gas", "Produced Oil", "Produced Water", "Salt Water", "Sea Water", "Unknown", "Water Based Mud" };
            public static string ToData(WellFluid enumer)
            {
                return _arr[(int)enumer];
            }
            public static WellFluid ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return WellFluid.NA;
                return (WellFluid)tmp;
            }
        }
        #endregion

        #region ServiceCoordinator
        public enum ServiceCoordinator { NA, RICHARD, BAROTO };
        public static class eServiceCoordinator
        {
            private static string[] _arr = { "N/A", "RICHARD SANKAR", "BADUNG BAROTO" };
            public static string ToData(ServiceCoordinator enumer)
            {
                return _arr[(int)enumer];
            }
            public static ServiceCoordinator ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return ServiceCoordinator.NA;
                return (ServiceCoordinator)tmp;
            }
        }
        #endregion

        #region ServicePlanner
        public enum ServicePlanner { NA, YUPHA };
        public static class eServicePlanner
        {
            private static string[] _arr = { "N/A", "YUPHA CHUMNUM" };
            public static string ToData(ServicePlanner enumer)
            {
                return _arr[(int)enumer];
            }
            public static ServicePlanner ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return ServicePlanner.NA;
                return (ServicePlanner)tmp;
            }
        }
        #endregion

        #region LoggingEngineer
        public enum LoggingEngineer { NA, DIEN, RORSALAN, RICHIE, PONG, KAY, THURDSAK, KEVIN };
        public static class eLoggingEngineer
        {
            private static string[] _arr = { "N/A", "DIEN VU", "RORSALAN HADKHAJAE", "PORNPRASERT PUTTANARAKUL", "PONGSAKORN SUWANNO", "ATTAGOWIT DISARA", "THURDSAK AROONTAT", "KEVIN HARRACKSINGH" };
            public static string ToData(LoggingEngineer enumer)
            {
                return _arr[(int)enumer];
            }
            public static LoggingEngineer ToEnum(string data)
            {
                string mperson = MatchPerson(data, _arr);
                int tmp = Array.IndexOf<string>(_arr, mperson);
                if (tmp == -1) return LoggingEngineer.NA;
                return (LoggingEngineer)tmp;
            }
        }
        #endregion

        /// <summary>
        /// Match a Person in Array of People by Name without Dot, if found dup then continue with Name without Dot
        /// </summary>
        /// <param name="name">person name to check</param>
        /// <param name="names">people names array</param>
        /// <returns>matched name in people names array or empty string</returns>
        private static string MatchPerson(string name, string[] names)
        {                        // Match nguyen truoc, sau khi match nguyen xong ma con trung thi moi match khong nguyen (co cham)
            // Vay phai tach duoc phan nguyen
            // Tach duoc phan co .
            // Sau do duyet mang _arr va regex. neu is match thi luu string vao mang tempmatch, duyet tiep neu match thi kiem tra xem mang temp match co trong khong
            //   neu trong tuc la khong sao, ghi vao mang
            //   neu khong trong tuc la trung truoc roi thi moi so phan khong nguyen.
            string prevMatch = string.Empty;
            foreach (string s in names)
            {
                Match matchNameNoDot = Regex.Match(s, @"(^|\s)[a-z]+(\s|$)", RegexOptions.IgnoreCase);
                if (matchNameNoDot == Match.Empty) continue;
                string nameNoDot = matchNameNoDot.ToString().Trim();
                // (^|\s) : LineStart hoac la space/tab (khong co dot, neu dot thi dung [^a-z0-9])
                // (\s|$) : tuong tu Space/Tab hoac la LineEnd
                // [a-z]+ : Ten phai la ky tu va xuat hien it nhat 1 lan
                // Toan bo nghia la : Tim ky tu bao boi space/tab hoac LineStart/LineEnd va toan la ky tu Tuc la Ten full khong viet tat (cham)

                if (Regex.IsMatch(name, @"(^|\s)" + nameNoDot + @"(\s|$)", RegexOptions.IgnoreCase))
                {   // Match NameNoDot already
                    if (prevMatch == string.Empty)
                    {   // Empty mean not match before, ghi vao match
                        prevMatch = s;
                    }
                    else
                    {   // Not empty mean match before, xet tiep den match nameDot
                        Match matchNameDot = Regex.Match(s, @"(^|\s)[a-z]+\.", RegexOptions.IgnoreCase);
                        if (matchNameDot == Match.Empty) continue;
                        string nameDot = matchNameDot.ToString().Trim();

                        if (Regex.IsMatch(name, nameDot, RegexOptions.IgnoreCase)) prevMatch = s; // Neu Match NameDot luon thi moi thay prevMatch, khong thi van giu nguyen last prevMatch
                        // Nhu vay prevMatch se lay Match NamNoDot dau tien hoac Match NameDot cuoi cung.
                    }
                }
                // Not Match NameNoDot -> Cu xet den het mang, neu No Match Any then prevMatch = Empty, check prevMatch to know which one to return
            }

            return prevMatch; // Empty hoac Ten nguoi, never match N/A so never return N/A. But ouside check empty not match anything then will assign N/A.
        }

        #region QualityCoordinator
        public enum QualityCoordinator { NA, JOSE };
        public static class eQualityCoordinator
        {
            private static string[] _arr = { "N/A", "JOSE ANTONIO RICO" };
            public static string ToData(QualityCoordinator enumer)
            {
                return _arr[(int)enumer];
            }
            public static QualityCoordinator ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return QualityCoordinator.NA;
                return (QualityCoordinator)tmp;
            }
        }
        #endregion

        #region CompanyMan
        public enum CompanyMan { NA, VITTAWAT, KITTISAK, WUTHISAK, NUTTAPON, JATUPORN, WICHAN, SANIT, KANTHAD };
        public static class eCompanyMan
        {
            private static string[] _arr = { "N/A", "VITTAWAT K.", "KITTISAK C.", "WUTHISAK N.", "NUTTAPON PI.", "JATUPORN SI.", "WICHAN C.", "SANIT B.", "KANTHAD P." };
            public static string ToData(CompanyMan enumer)
            {
                return _arr[(int)enumer];
            }
            public static CompanyMan ToEnum(string data)
            {
                // Match nguyen truoc, sau khi match nguyen xong ma con trung thi moi match khong nguyen (co cham)
                // Vay phai tach duoc phan nguyen
                // Tach duoc phan co .
                // Sau do duyet mang _arr va regex. neu is match thi luu string vao mang tempmatch, duyet tiep neu match thi kiem tra xem mang temp match co trong khong
                //   neu trong tuc la khong sao, ghi vao mang
                //   neu khong trong tuc la trung truoc roi thi moi so phan khong nguyen.
                string prevMatch = string.Empty;
                foreach (string s in _arr)
                {
                    Match matchNameNoDot = Regex.Match(s, @"(^|\s)[a-z]+(\s|$)", RegexOptions.IgnoreCase);
                    if (matchNameNoDot == Match.Empty) continue;
                    string nameNoDot = matchNameNoDot.ToString().Trim();
                    // (^|\s) : LineStart hoac la space/tab (khong co dot, neu dot thi dung [^a-z0-9])
                    // (\s|$) : tuong tu Space/Tab hoac la LineEnd
                    // [a-z]+ : Ten phai la ky tu va xuat hien it nhat 1 lan
                    // Toan bo nghia la : Tim ky tu bao boi space/tab hoac LineStart/LineEnd va toan la ky tu Tuc la Ten full khong viet tat (cham)

                    if (Regex.IsMatch(data, @"(^|\s)" + nameNoDot + @"(\s|$)", RegexOptions.IgnoreCase))
                    {   // Match NameNoDot already
                        if (prevMatch == string.Empty)
                        {   // Empty mean not match before, ghi vao match
                            prevMatch = s;
                        }
                        else
                        {   // Not empty mean match before, xet tiep den match nameDot
                            Match matchNameDot = Regex.Match(s, @"(^|\s)[a-z]+\.", RegexOptions.IgnoreCase);
                            if (matchNameDot == Match.Empty) continue;
                            string nameDot = matchNameDot.ToString().Trim();

                            if (Regex.IsMatch(data, nameDot, RegexOptions.IgnoreCase)) prevMatch = s; // Neu Match NameDot luon thi moi thay prevMatch, khong thi van giu nguyen last prevMatch
                            // Nhu vay prevMatch se lay Match NamNoDot dau tien hoac Match NameDot cuoi cung.
                        }
                    }
                    // Not Match NameNoDot -> Cu xet den het mang, neu No Match Any then prevMatch = Empty, check prevMatch to know which one to return
                }

                if (prevMatch == string.Empty) return CompanyMan.NA; // Khong match duoc thang nao het
                else return (CompanyMan)Array.IndexOf(_arr, prevMatch); // Always match because prevMatch = s in _arr

                /*int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return CompanyMan.NA;
                return (CompanyMan)tmp;*/
            }
        }
        #endregion

        #region PipeFunction
        public enum PipeFunction
        {
            NA, BLANK_PIPE, BRIDGE_PLUG, CEMENT_PLUG, CEMENT_STAGE_TOOL, CLOSE_SLEEVE, COIL_TUBING,
            CONDUCTOR_CASING, DRILL_COLLAR, DRILL_PIPE, DRILL_LINER, DRIVE_PIPE, EXPANDABLE_CASING, FRAC_BAFFLE, GAP_ON_WELL_CASING,
            HANGER, INTERMEDIATE_CASING, JET_PIPE, LOWER_EXTENSION, NIPPLE, OPEN_HOLE_SECTION, PACKER, PRODUCTION_CASING,
            PRODUCTION_LINER, RETAINER, RISER, SAND_PLUG, SCAB_LINER, SCREEN, SLOTTED_LINER, SURFACE_CASING, TIEBACK, TUBING,
            UPPER_EXTENSION, WELL_PLUG, WELLHEAD, WORKSTRING, X_OVER
        };
        public static class ePipeFunction
        {
            private static string[] _arr = { "N/A", "Blank Pipe", "Bridge Plug", "Cement Plug", "Cement Stage Tool", "Closing Sleeve", "Coil Tubing",
                                             "Conductor Casing", "Drill Collar", "Drill Pipe", "Drilling Liner", "Drive Pipe", "Expandable Casing", "Frac Baffle", "Gap on Well Casing", 
                                             "Hanger", "Intermediate Casing", "Jet Pipe", "Lower Extension", "Nipple", "Open Hole Section", "Packer", "Production Casing", 
                                             "Production Liner", "Retainer", "Riser", "Sand Plug", "Scab Liner", "Screen", "Slotted Liner", "Surface Casing", "Tieback", "Tubing", 
                                             "Upper Extension", "Well Plug", "Wellhead", "Workstring", "X-Over" };
            public static string ToData(PipeFunction enumer)
            {
                return _arr[(int)enumer];
            }
            public static PipeFunction ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return PipeFunction.NA;
                return (PipeFunction)tmp;
            }
        }
        #endregion

        #region PipeType
        public enum PipeType
        {
            NA, CASING, COIL_TUBING, DRILL_COLLAR, DRILL_PIPE, EXPANDABLE_CASING,
            EXPANDABLE_TUBING, GAP_ON_WELL_CASING, LINE_PIPE, TUBING, WELL_PLUG
        };
        public static class ePipeType
        {
            private static string[] _arr = { "N/A", "Casing", "Coil Tubing", "Drill Collar", "Drill Pipe", "Expandable Casing", 
                                             "Expandable Tubing", "Gap on Well Casing", "Line Pipe", "Tubing", "Well Plug" };
            public static string ToData(PipeType enumer)
            {
                return _arr[(int)enumer];
            }
            public static PipeType ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return PipeType.NA;
                return (PipeType)tmp;
            }
        }
        #endregion

        #region PipeGrade
        public enum PipeGrade { NA, _100MY, _105MY, _110MY, _120MY, _125MY };
        public static class ePipeGrade
        {
            private static string[] _arr = { "N/A", "100 MY", "105 MY", "110 MY", "120 MY", "125 MY" };
            public static string ToData(PipeGrade enumer)
            {
                return _arr[(int)enumer];
            }
            public static PipeGrade ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return PipeGrade.NA;
                return (PipeGrade)tmp;
            }
        }
        #endregion

        #region GunSize
        public enum GunSize { NA, _2IN, _1IN11_16 };
        public static class eGunSize
        {
            private static string[] _arr = { "N/A", "2", "1.6875" };
            public static string ToData(GunSize enumer)
            {
                return _arr[(int)enumer];
            }
            public static GunSize ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return GunSize.NA;
                return (GunSize)tmp;
            }
        }
        #endregion

        #region SPF
        public enum SPF { NA, _6SPF };
        public static class eSPF
        {
            private static string[] _arr = { "N/A", "6" };
            public static string ToData(SPF enumer)
            {
                return _arr[(int)enumer];
            }
            public static SPF ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return SPF.NA;
                return (SPF)tmp;
            }
        }
        #endregion

        #region Polarity
        public enum Polarity { NA, POSITIVE, NEGATIVE };
        public static class ePolarity
        {
            private static string[] _arr = { "N/A", "+", "-" };
            public static string ToData(Polarity enumer)
            {
                return _arr[(int)enumer];
            }
            public static Polarity ToEnum(string data)
            {
                int tmp = Array.IndexOf<string>(_arr, data);
                if (tmp == -1) return Polarity.NA;
                return (Polarity)tmp;
            }
        }
        #endregion

        public static class Unit
        {
            public enum Style { NA, PTTEP, CHEVRON };

            #region Pressure
            public enum Pressure { NA, ATM, BAR, kPA, kPAG, MPA, MPAG, PA, PSI, PSIA, PSIG };
            public static class ePressure
            {
                private static string[] _arr = { "N/A", "atm", "bar", "kPa", "kPag", "MPa", "MPag", "Pa", "psi", "psia", "psig" };
                public static string ToData(Pressure enumer)
                {
                    return _arr[(int)enumer];
                }
                public static Pressure ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return Pressure.NA;
                    return (Pressure)tmp;
                }
            }
            #endregion

            #region Temperature
            public enum Temperature { NA, degC, degF, degK, degR };
            public static class eTemperature
            {
                private static string[] _arr = { "N/A", "degC", "degF", "degK", "degR" };
                public static string ToData(Temperature enumer)
                {
                    return _arr[(int)enumer];
                }
                public static Temperature ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return Temperature.NA;
                    return (Temperature)tmp;
                }
            }
            #endregion

            #region Distance
            public enum Distance { NA, CM, FT, IN, M, MM, YARD };
            public static class eDistance
            {
                private static string[] _arr = { "N/A", "cm", "ft", "in", "m", "mm", "yd" };
                public static string ToData(Distance enumer)
                {
                    return _arr[(int)enumer];
                }
                public static Distance ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return Distance.NA;
                    return (Distance)tmp;
                }
            }
            #endregion

            #region Resistivity
            public enum Resistivity { NA, OHM_M };
            public static class eResistivity
            {
                private static string[] _arr = { "N/A", "ohm/m" };
                public static string ToData(Resistivity enumer)
                {
                    return _arr[(int)enumer];
                }
                public static Resistivity ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return Resistivity.NA;
                    return (Resistivity)tmp;
                }
            }
            #endregion

            #region Concentration
            public enum Concentration { NA, MG_L, PPM };
            public static class eConcentration
            {
                private static string[] _arr = { "N/A", "mg/L", "ppm" };
                public static string ToData(Concentration enumer)
                {
                    return _arr[(int)enumer];
                }
                public static Concentration ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return Concentration.NA;
                    return (Concentration)tmp;
                }
            }
            #endregion

            #region Degree
            public enum Degree { NA, DEG, RAD };
            public static class eDegree
            {
                private static string[] _arr = { "N/A", "DEG", "rad" };
                public static string ToData(Degree enumer)
                {
                    return _arr[(int)enumer];
                }
                public static Degree ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return Degree.NA;
                    return (Degree)tmp;
                }
            }
            #endregion

            #region DogLeg
            public enum DogLeg { NA, DEG_1000FT, DEG_100FT, DEG_10M, DEG_30M, RAD_100FT, RAD_10M, RAD_30M };
            public static class eDogLeg
            {
                private static string[] _arr = { "N/A", "deg/1000ft", "deg/100ft", "deg/10m", "deg/30m", "rad/100ft", "rad/10m", "rad/30m" };
                public static string ToData(DogLeg enumer)
                {
                    return _arr[(int)enumer];
                }
                public static DogLeg ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return DogLeg.NA;
                    return (DogLeg)tmp;
                }
            }
            #endregion

            #region WeightMud
            public enum WeightMud { NA, G_CM3, KG_M3, LB_BBL, LB_FT3, LB_GAL, LB_IN3, PPG, SG };
            public static class eWeightMud
            {
                private static string[] _arr = { "N/A", "g/cm3", "kg/m3", "lbm/bbl", "lbm/ft3", "lbm/gal", "lbm/in3", "ppg", "SG" };
                public static string ToData(WeightMud enumer)
                {
                    return _arr[(int)enumer];
                }
                public static WeightMud ToEnum(string data)
                {
                    int tmp = Array.IndexOf<string>(_arr, data);
                    if (tmp == -1) return WeightMud.NA;
                    return (WeightMud)tmp;
                }
            }
            #endregion
        }

    }
}
